//
//  RightRecommendTableViewCell.m
//  项目A_百思不得姐
//
//  Created by wudongyang on 16/5/26.
//  Copyright © 2016年 wudongyang. All rights reserved.
//

#import "RightRecommendTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation RightRecommendTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self DSSubViews];
    }
    return self;
}

-(void)DSSubViews{
    self.headImageV = [[UIImageView alloc] init];
    self.headImageV.backgroundColor = [UIColor whiteColor];
    self.headImageV.layer.masksToBounds = YES;
    self.headImageV.layer.cornerRadius = 20;
    [self.contentView addSubview:self.headImageV];
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.nameLabel];
    
    self.fansLabel = [[UILabel alloc] init];
    self.fansLabel.backgroundColor = [UIColor clearColor];
    self.fansLabel.textColor = DSRGBA(104, 104, 104, 1);
    self.fansLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.fansLabel];
    
    self.GZButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.GZButton.backgroundColor = [UIColor clearColor];
//    [self.GZButton setBackgroundImage:[UIImage imageNamed:@"guanzhu2"] forState:UIControlStateNormal];
    [self.GZButton setTitle:@"+关注" forState:UIControlStateNormal];
    [self.GZButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    self.GZButton.layer.borderWidth = 0.5;
    self.GZButton.layer.borderColor =  [DSRGBA(96, 96, 96, 1) CGColor];
    self.GZButton.layer.masksToBounds = YES;
    self.GZButton.layer.cornerRadius = 4;
    
    [self.contentView addSubview:self.GZButton];
    [self.GZButton addTarget:self action:@selector(GZButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.bigView = [[UIView alloc] init];
    self.bigView.backgroundColor = DSRGBA(223, 223, 223, 1);
    [self.contentView addSubview:self.bigView];
    
    self.HYImageV = [[UIImageView alloc] init];
    self.HYImageV.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.HYImageV];
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.headImageV.frame = CGRectMake(10, 10, 40, 40);
    self.nameLabel.frame = CGRectMake(60, 10, 120, 20);
    self.fansLabel.frame = CGRectMake(60, 35, 120, 15);
    self.bigView.frame = CGRectMake(0, 59, self.contentView.frame.size.width, 1);
    self.HYImageV.frame = CGRectMake(180, 10, 20, 20);
    self.GZButton.frame = CGRectMake(260, 15, 60, 30);
}
-(void)setRightModel:(RightRecommendModel *)rightModel{
    _rightModel = rightModel;
    [self.headImageV sd_setImageWithURL:[NSURL URLWithString:_rightModel.header] placeholderImage:[UIImage imageNamed:@"tupian1.jpeg"]];
    self.nameLabel.text = _rightModel.screen_name;
    NSString *str = [NSString stringWithFormat:@"%@人关注",_rightModel.fans_count];
    self.fansLabel.text = str;
    
    // 判断是不是会员NSNumber类型
    if ([self.rightModel.is_vip isEqualToNumber:@1]) {
        self.HYImageV.image = [UIImage imageNamed:@"huiyuan.gif"];
        self.nameLabel.textColor = DSRGBA(219, 52, 35, 1);
    } else {
        self.HYImageV.image = nil;
        self.nameLabel.textColor = [UIColor blackColor];
    }
}
-(void)GZButtonAction:(UIButton *)button{
    DSLog(@"关注按钮点击方法");
    self.GZBlock(button);
    
}





@end
